package com.example.showlistexample;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private Toolbar toolbar;
    private List<InfoBean> mList = new ArrayList();
    private InfoAdapter mAdapter;
    private RecyclerView mRecyclerview;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        toolbar = findViewById(R.id.toolbar);
        mRecyclerview = findViewById(R.id.recycler_view);
        toolbar.setTitle("营养师信息");
        setSupportActionBar(toolbar);
//        getSupportActionBar().setDisplayHomeAsUpEnabled(true);//左侧添加一个默认的返回图标
//        getSupportActionBar().setHomeButtonEnabled(true); //设置返回键可用
//        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                finish();
//            }
//        });
        InfoBean infoBean1 = new InfoBean(R.mipmap.ico1, "王阿姨", "二级营养师", "￥5000/月", "美丽大方");
        InfoBean infoBean2 = new InfoBean(R.mipmap.ico2, "李阿姨", "三级营养师", "￥7000/月", "擅长西餐");
        InfoBean infoBean3 = new InfoBean(R.mipmap.ico3, "孙阿姨", "一级营养师", "￥5000/月", "擅长各大菜系");
        InfoBean infoBean4 = new InfoBean(R.mipmap.ico4, "杨阿姨", "特级级营养师", "￥12000/月", "温柔善良");
        InfoBean infoBean5 = new InfoBean(R.mipmap.ico5, "袁阿姨", "四级营养师", "￥10000/月", "性格大方");
        InfoBean infoBean6 = new InfoBean(R.mipmap.ico6, "谭阿姨", "二级营养师", "￥6000/月", "学历优异");
        InfoBean infoBean7 = new InfoBean(R.mipmap.ico7, "赵阿姨", "三级营养师", "￥7000/月", "注重细节");
        InfoBean infoBean8 = new InfoBean(R.mipmap.ico6, "潘阿姨", "一级营养师", "￥4000/月", "勇于钻研");
        mList.add(infoBean1);
        mList.add(infoBean2);
        mList.add(infoBean3);
        mList.add(infoBean4);
        mList.add(infoBean5);
        mList.add(infoBean6);
        mList.add(infoBean7);
        mList.add(infoBean8);
        mAdapter = new InfoAdapter(mList);
        mRecyclerview.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerview.setAdapter(mAdapter);
        mAdapter.notifyDataSetChanged();

    }
}